﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Text;
using Windows.Foundation;
using Windows.UI.Xaml;

namespace AppDemo
{
    public class ExplorerViewProperties : INotifyPropertyChanged
    {

        public double ButtonWidth { get { return buttonSize.Width; } }
        public double ButtonHeight { get { return buttonSize.Height; } }

        Size buttonSize;
        public Size ButtonSize
        {
            get { return buttonSize; }
            set
            {
                if (SetValue(ref buttonSize, value))
                {
                    RaisePropertyChanged("ButtonWidth");
                    RaisePropertyChanged("ButtonHeight");
                };
            }
        }

        Visibility showAdvanced;
        public Visibility ShowAdvanced
        {
            get { return showAdvanced; }
            set { SetValue(ref showAdvanced, value); }
        }

        bool SetValue<T>(ref T currentValue, T newValue, [CallerMemberName] string name = "")
        {
            if (object.Equals(currentValue, newValue))
                return false;

            currentValue = newValue;
            RaisePropertyChanged(name);
            return true;
        }

        public event PropertyChangedEventHandler PropertyChanged;
        void RaisePropertyChanged([CallerMemberName] string propertyName = "")
        {
            var handler = PropertyChanged;
            if (handler != null)
            {
                try
                {
                    handler(this, new PropertyChangedEventArgs(propertyName));
                }
                catch (Exception ex)
                {
                    Debug.WriteLine("Error raising property {0}: {1}", propertyName, ex.Message);
                }
            }
        }

        public ExplorerViewProperties()
        {
            buttonSize = new Size(80, 80);
            showAdvanced = Visibility.Visible;
        }
    }
}
